package com.zzty.common;

//import com.zzty.entity.Question;

import com.zzty.entity.Question;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Refe {
    //   https://blog.csdn.net/sinat_38259539/article/details/71799078
    public static void main(String[] args) throws Exception{
        //Class clazz=Class.forName("com.zzty.entity.Question");
        Class clazz=Question.class;
        Field[] field=clazz.getDeclaredFields();
        for(Field f:field){
            System.out.println(f.toString());
        }
        System.out.println("=====================");
        Method[] methods=clazz.getDeclaredMethods();
        for(Method method:methods){
            System.out.println(method.toString());

        }
        System.out.println("=====================");
        Constructor[] constructor=clazz.getDeclaredConstructors();
        for(Constructor c:constructor){
            System.out.println(c.toString());
        }

        //Question question =new Question();

        Object obj=clazz.newInstance();

        Field fid=clazz.getDeclaredField("id");
        fid.setAccessible(true);
        fid.set(obj,122);

        System.out.println(fid.get(obj));


        Method mSetId=clazz.getDeclaredMethod("setId",Integer.class);
        mSetId.invoke(obj,1111);


        Method mGetId=clazz.getDeclaredMethod("getId");
        Object result=mGetId.invoke(obj);
        System.out.println("result"+result);





    }
}
